home *** CD-ROM | disk | FTP | other *** search
- //***************************************************************************
- //
- // Simple string output benchmark.
- // Using MFC Time Class
- //
- //
- // Written by: Karl Weller
- // CI$: [74620,2112]
- //
- //***************************************************************************
- #define _DOS
- #include "stdio.h"
- #include "stdlib.h"
- #include "conio.h"
- #include "time.h"
- #include "iostream.h"
- #include "afx.h"
-
- char far *scr; // Display pointer for memory output
-
- //**************************************************************************
- //
- // Set up char far *scr to point to the correct video address.
- // Clear the display.
- //
- //**************************************************************************
- void cldisp(void )
- {
- register int i=0;
-
- if ((*((char far *)(0L + 0x410)) & 0x30) != 0x30)
- scr = (char far *)0xb8000000; // Color
- else
- scr = (char far *)0xb0000000; // Mono
-
- while (i<4000) {
- *(scr+(i++*2)) = ' ';
- }
- }
-
- //**************************************************************************
- //
- // Display the string
- //
- //**************************************************************************
- void disp(CString s)
- {
- register int i=0;
- while (s[i]) {
- *(scr+(i*2)) = s[i];
- ++i;
- }
- }
-
- int main()
- {
- int cnt = 0;
- CTime t1;
- CString s;
-
- cldisp();
- while(!kbhit()) {
- cnt = 0;
- // Locate the cursor at 0,0
- _asm {
- mov ah,02
- xor dx,dx
- xor bx,bx
- int 10h
- }
- t1 = CTime::GetCurrentTime();
- while(t1 == CTime::GetCurrentTime()); // Wait for the time to change
- t1 = CTime::GetCurrentTime();
- while(t1 == CTime::GetCurrentTime()) { // Loop for a second
- s = t1.Format("%A, %B %d, %Y %I:%M:%S%p");
- disp(s); // Display using video ram
- ++cnt;
- }
- cout << "\nNumber of times it was displayed using memory out " << cnt << endl;
-
- cnt = 0;
- // Locate the cursor at 0,0
- _asm {
- mov ah,02
- xor dx,dx
- xor bx,bx
- int 10h
- }
- t1 = CTime::GetCurrentTime();
- while(t1 == CTime::GetCurrentTime());
- t1 = CTime::GetCurrentTime();
- while(t1 == CTime::GetCurrentTime()) {
- s = t1.Format("%A, %B %d, %Y %I:%M:%S%p");
- printf("%s\r",s);
- ++cnt;
- }
- cout << "\n\nNumber of times it was displayed using printf " << cnt << endl;
-
- cnt = 0;
- // Locate the cursor at 0,0
- _asm {
- mov ah,02
- xor dx,dx
- xor bx,bx
- int 10h
- }
- t1 = CTime::GetCurrentTime();
- while(t1 == CTime::GetCurrentTime());
- t1 = CTime::GetCurrentTime();
- while(t1 == CTime::GetCurrentTime()) {
- s = t1.Format("%A, %B %d, %Y %I:%M:%S%p");
- cout << s << "\r";
- ++cnt;
- }
- cout << "\n\n\nNumber of times it was displayed using cout " << cnt << endl;
- }
- return(0);
- }